package com.cloudfun.campusshare.controller;

import com.cloudfun.campusshare.common.constant.Code;
import com.cloudfun.campusshare.common.constant.RoleType;
import com.cloudfun.campusshare.common.model.dto.RepairCreateDTO;
import com.cloudfun.campusshare.common.response.BaseResult;
import com.cloudfun.campusshare.common.response.BaseResultFactory;
import com.cloudfun.campusshare.common.security.AuthRequired;
import com.cloudfun.campusshare.service.RepairService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Huqin on 2020/4/22
 */
@RestController
@RequestMapping("/v1/repair")
@Api(value = "报修模块", description = "报修模块")
public class RepairController {

    @Autowired
    private RepairService repairService;

    @ApiOperation("创建报修")
    @PutMapping("/create")
    @AuthRequired(role = RoleType.CUSTOMER)
    public BaseResult<?> create(@ApiParam(value = "repairCreateDTO", required = true) @RequestBody RepairCreateDTO createDTO) {
        repairService.create(createDTO);
        return BaseResultFactory.produceResult(Code.SUCCESS, "成功");
    }
}
